/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import Dao.ProfessorDao;
import Dao.ProfessorDaoImplJPA;
import Pojo.Professor;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author thiago schons
 */
public class ProfessorDaoImplJPATeste {
    
    public ProfessorDaoImplJPATeste() {
    }
    
    @BeforeClass
    public static void setUpClass() {
    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }
    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //
    // @Test
    // public void hello() {}
    
    @Test
    public void inserirDaCerto(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        Professor professor = new Professor(1,"Thiago","11122233344","dcomp");
        assertTrue(professorDao.inserir(professor));
    }
           
    @Test
    public void alterarDaCerto(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        Professor professor = new Professor(1,"Teló","11122233344","dcomp");
        assertTrue(professorDao.alterar(professor));
    }
    
    @Test
    public void alterarDaErrado(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        Professor professor = new Professor(2,"manolo","11122233344","dcomp");
        assertFalse(professorDao.alterar(professor));
    }
    
    @Test
    public void removerDaCerto(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        Professor professor = new Professor(1,"Thiago","11122233344","dcomp");
        assertTrue(professorDao.remover(professor));
    }
    
    @Test
    public void removerDaErrado(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        Professor professor = new Professor(3,"Silvestre","11122233344","dcomp");
        assertFalse(professorDao.remover(professor));
    }
    
    @Test
    public void pesquisarTodosDaCerto(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        Professor professor = new Professor(1,"Thiago","11122233344","dcomp");
        professorDao.inserir(professor);
        assertNotSame(0,professorDao.pesquisarTodos().size());
    }
    
    @Test
    public void pesquisarPorCpfDaCerto(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        assertNotNull(professorDao.pesquisarPorCpf("11122233344"));
    }
    
    @Test
    public void pesquisarPorCpfDaErrado(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        assertNull(professorDao.pesquisarPorCpf(""));
    }
    
    @Test
    public void pesquisarPorNomeDaCerto(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        assertNotSame(0,professorDao.pesquisarPorNome("Thiago").size());
    }
    
    @Test
    public void pesquisarPorNomeDaErrado(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        assertSame(0,professorDao.pesquisarPorNome("Sirius").size());
    }
    
    @Test
    public void pesquisarPorIdDaCerto(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        assertNotNull(professorDao.pesquisarPorId(1));
    }
    
    @Test
    public void pesquisarPorIdDaErrado(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        assertNull(professorDao.pesquisarPorId(1203));
    }
    
    @Test
    public void pesquisarPorDepartamentoDaCerto(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        assertNotSame(0,professorDao.pesquisarPorDepartamento("dcomp").size());
    }
    
    @Test
    public void pesquisarPorDepartamentoDaErrado(){
        ProfessorDao professorDao = new ProfessorDaoImplJPA();
        assertSame(0,professorDao.pesquisarPorDepartamento("dcc").size());
    }
}